package com.shaoyu.tools.testcase.flow;

import com.shaoyu.spring.study.annotation.HandlerExecutor;
import com.shaoyu.spring.study.dto.BaseRequest;
import com.shaoyu.spring.study.dto.BaseResponse;
import com.shaoyu.spring.study.handler.BasicHandler;
import com.shaoyu.spring.study.runner.HandlerContext;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @Desc :
 * @Author: shaoyu
 * @Date : 2022/3/1 15:11
 */
@HandlerExecutor(groups = FlowTestService.GROUP)
public class FlowFirstHandler extends BasicHandler<OrderDTO,OrderDTO> {
    @Override
    public void run(BaseRequest<OrderDTO> request, BaseResponse<OrderDTO> response, HandlerContext context) {

        List<String> productNames = request.get("productNames");
        if(CollectionUtils.isEmpty(productNames)){
            productNames = productNames==null?new ArrayList<>():productNames;
            for (int i = 0; i < 10; i++) {
                productNames.add(i+"商品名字");
            }
        }
        response.set("productNames",productNames);
    }
}
